package com.longteng.diamond.dao;

import com.longteng.diamond.domain.ProjectShareNode;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * Created by Administrator
 * DATE : 2018/7/23
 * TIME : 22:18
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:taki@qq.com">Administrator</a>
 */
@Mapper
public interface ProjectModuleMapper extends BaseMapper  {
    /**
     * 查询项目模块
     * @param projectShareNode
     * @return
     */
    @Override
    @Select("select * from project_module where yn =1 and projectId=#{projectId} limit #{pageNo} , #{pageSize} ")
    List<ProjectShareNode> getProjectShareNode(ProjectShareNode projectShareNode);
    /**
     * 查询host、模块、项目成员所有行数
     * @param projectShareNode
     * @return
     */
    @Override
    @Select("select count(*) from project_module where yn =1 and projectId=#{projectId}")
    long queryAllRow(ProjectShareNode projectShareNode);
    /**
     * 根据id查询项目成员
     * @param id
     * @return
     */
    @Override
    @Select("select * from project_module where id=#{id}")
    ProjectShareNode findProjectShareNodeById(Integer id);
    /**
     * 新增项目成员
     * @param projectShareNode
     * @return
     */
    @Insert("insert into project_module(moduleName,projectId,createTime,updateTime,yn) " +
            "values(#{moduleName},#{projectId},now(),now(),1)")
    void addProjectShareNode(ProjectShareNode projectShareNode);
    /**
     * 修改项目模块
     * @param projectShareNode
     * @return
     */
    @Update("update project_module set moduleName =#{moduleName},updateTime=now() where id =#{id}")
    void updateProjectShareNode(ProjectShareNode projectShareNode);
    /**
     * 删除项目模块
     * @param id
     * @return
     */
    @Delete("update project_module set yn =0,updateTime=now() where id =#{id}")
    void deleteProjectShareNode(Integer id);
    /**
     * 模块名称获取项目模块
     * @param projectShareNode
     * @return
     */
    @Select("select * from project_module where yn =1 and moduleName=#{moduleName} and projectId=#{projectId}")
    ProjectShareNode findProjectModuleByName(ProjectShareNode projectShareNode);

    /**
     * 模块名称获取项目模块
     * @param projectId
     * @return
     */
    @Select("select * from project_module where yn =1 and  projectId=#{projectId}")
    List<ProjectShareNode> findProjectModuleByProjectId(@Param("projectId") Integer projectId);
}
